home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-I386 / TIMEX.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  1KB  |  48 lines

  1. /*
  2.  * linux/include/asm-i386/timex.h
  3.  *
  4.  * i386 architecture timex specifications
  5.  */
  6. #ifndef _ASMi386_TIMEX_H
  7. #define _ASMi386_TIMEX_H
  8.  
  9. #include <linux/config.h>
  10.  
  11. #define CLOCK_TICK_RATE    1193180 /* Underlying HZ */
  12. #define CLOCK_TICK_FACTOR    20    /* Factor of both 1000000 and CLOCK_TICK_RATE */
  13. #define FINETUNE ((((((long)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
  14.     (1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
  15.         << (SHIFT_SCALE-SHIFT_HZ)) / HZ)
  16.  
  17. /*
  18.  * Standard way to access the cycle counter on i586+ CPUs.
  19.  * Currently only used on SMP.
  20.  *
  21.  * If you really have a SMP machine with i486 chips or older,
  22.  * compile for that, and this will just always return zero.
  23.  * That's ok, it just means that the nicer scheduling heuristics
  24.  * won't work for you.
  25.  *
  26.  * We only use the low 32 bits, and we'd simply better make sure
  27.  * that we reschedule before that wraps. Scheduling at least every
  28.  * four billion cycles just basically sounds like a good idea,
  29.  * regardless of how fast the machine is. 
  30.  */
  31. typedef unsigned long cycles_t;
  32.  
  33. extern cycles_t cacheflush_time;
  34.  
  35. static inline cycles_t get_cycles (void)
  36. {
  37. #ifndef CONFIG_X86_TSC
  38.     return 0;
  39. #else
  40.     unsigned long eax, edx;
  41.  
  42.     __asm__ __volatile__("rdtsc":"=a" (eax), "=d" (edx));
  43.     return eax;
  44. #endif
  45. }
  46.  
  47. #endif
  48.